﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace EITSurferInfinityLib
{
    static public class LoadHwP_st_1_xpxx_3p0
    {
        static string path = @"hardware settings\swisstom\st_1_xpxx_3p0\";

        public static double GetVtoILinearValue(string fileName)
        {
            double d =-1;
            d=Convert.ToDouble(GetParameterByName(fileName, "r54", 1));
            return d;
        }

        public static double GetVRefDac(string fileName)
        {
            double d = -1;
            d = Convert.ToDouble(GetParameterByName(fileName, "VRefDac", 1));
            return d;
        }

        public static double GetADCSamplingPeriodMin(string fileName)
        {
            double d = -1;
            d = Convert.ToDouble(GetParameterByName(fileName, "ADCSamplingPeriodMin", 1));
            return d;
        }

        static string GetParameterByName(string fileName, string paramName, int valuePosition)
        {
            string s=null;
            StreamReader myFile = new StreamReader(path + fileName + ".txt");

            string line;
            while ((line = myFile.ReadLine()) != null)
            {
                if (line.Contains(paramName))
                {
                    string[] split = line.Split();
                    s=split[1];
                }
            }

            myFile.Close();
            return s;
        }
    }
}
